package org.zfes.snowier.cloud.zbss.cms.router.service.origin;

import java.util.Map;
import java.util.Optional;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.zfes.snowier.core.data.DataSet;
import org.zfes.snowier.web.controller.BaseController;
import org.zfes.snowier.cloud.zbss.cms.origin.model.CmsOrigin;
import org.zfes.snowier.cloud.zbss.cms.origin.service.ICmsOriginService;
@Controller 
@RequestMapping("/cms/origin/cmsOrigin")
public class CmsOriginController extends BaseController {

	
	@Autowired
	private ICmsOriginService cmsOriginService;
	
	@RequiresPermissions(value="cmsOrigin:loadCmsOriginDataSet",desc="来源列表")
    @RequestMapping(value="/loadCmsOriginDataSet", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object loadCmsOriginDataSet(@RequestParam Map<String,Object> params){
	    DataSet dataSet=  cmsOriginService.loadCmsOriginDataSet(params);
	    return ajaxQuery("dataSet", dataSet);
    }
	
	@RequiresPermissions(value="cmsOrigin:createCmsOrigin",desc="来源添加")
    @RequestMapping(value="/createCmsOrigin", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public  @ResponseBody Object createCmsOrigin(CmsOrigin cmsOrigin){
		cmsOriginService.createCmsOrigin(cmsOrigin);
    	return ajaxDoneSuccess("数据操作成功 ");
    }
	
	@RequiresPermissions(value="cmsOrigin:loadCmsOrigin",desc="来源加载")
    @RequestMapping(value="/loadCmsOrigin", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object loadCmsOrigin(Long id){
		Optional<CmsOrigin> ops = cmsOriginService.loadCmsOriginById(id);
		return ajaxQuery("cmsOrigin",ops);
    }
	
	@RequiresPermissions(value="cmsOrigin:updateCmsOrigin",desc="来源更新")
    @RequestMapping(value="/updateCmsOrigin", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object updateCmsOrigin(CmsOrigin cmsOrigin){
		cmsOriginService.updateCmsOrigin(cmsOrigin);
		return ajaxDoneSuccess("数据操作成功 ");
    }
	
	@RequiresPermissions(value="cmsOrigin:deletCmsOrigin",desc="来源删除")
    @RequestMapping(value="/deleteCmsOrigin", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object deleteCmsOrigin(Long id){
		cmsOriginService.deleteCmsOrigin(id);
		return ajaxDoneSuccess("数据操作成功 ");
    }

}